package com.masterrabbit.sn.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.masterrabbit.sn.domain.Activities;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
* @author 13119
* @description 针对表【activities】的数据库操作Mapper
* @createDate 2025-03-18 10:00:39
* @Entity com/masterrabbit/sn.domain.Activities
*/
@Mapper
public interface ActivitiesMapper extends BaseMapper<Activities> {
    /**
     * 根据上架情况查询活动
     * @param page
     * @param merchantId
     * @return
     */
    @Select("SELECT * FROM activities WHERE merchant_id = #{merchantId} AND is_online = 1")
    Page<Activities> selectOfflineActivities(Page<Activities> page, @Param("merchantId") Integer merchantId);
    /**
     * 根据上架情况查询活动
     * @param page
     * @param merchantId
     * @return
     */
    @Select("SELECT * FROM activities WHERE merchant_id = #{merchantId} AND is_online = 2")
    Page<Activities> selectOnlineActivities(Page<Activities> page, @Param("merchantId") Integer merchantId);
    /**
     * 上架活动
     * @param activitiesId
     * @return
     */
    @Update("update activities set is_online = 2 where activity_id = #{activitiesId}")
    int updateOnlineActivities(@Param("activitiesId") Integer activitiesId);
    /**
     * 下架活动
     * @param activitiesId
     * @return
     */
    @Update("update activities set is_online = 1 where activity_id = #{activitiesId}")
    int updateOfflineActivities(@Param("activitiesId") Integer activitiesId);
}




